package com.bwie.controller;

import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbOrderService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/6/26 15:09
 */

@RestController
@RequestMapping("/shop/order")
public class OrderController {

    @Autowired
    TbOrderService tbOrderService;

    /**
     * @description 订单分页列表
     * @params [pageInfoVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/26 15:25
     */
    @PostMapping("/getOrderList")
    public R getOrderList(@RequestBody PageInfoVo pageInfoVo) {
        return tbOrderService.getOrderList(pageInfoVo);
    }

    /**
     * @description 新增订单
     * @params [infoList]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/27 8:10
     */
    @PostMapping("/addOrder")
    public R addOrder(@RequestBody List<TbProdInfo> infoList) {
        return tbOrderService.addOrder(infoList);
    }

    /**
     * @description 导出订单列表
     * @params []
     * @return void
     * @author 军哥
     * @date 2025/6/27 15:48
     */
    @GetMapping("/exportOrderList/{userId}")
    public void exportOrderList(@PathVariable("userId") Integer userId) {
        tbOrderService.exportOrderList(userId);
    }

    /**
     * @description 根据订单ID获取订单详情
     * @params [orderId]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/7/1 11:35
     */
    @PostMapping("/getOrderInfoById/{orderId}")
    public R getOrderInfoById(@PathVariable("orderId") Integer orderId) {
        return tbOrderService.getOrderInfoById(orderId);
    }

}
